# 创建数据连接引擎
from llama_index.core import SQLDatabase, Settings
from llama_index.core.indices.struct_store import NLSQLTableQueryEngine
from sqlalchemy import create_engine
from llms import deepseek_llm
from embeddings import embed_model_local_bge_small
# Settings.embed_model = embed_model_local_bge_small()
engine = create_engine("mysql+pymysql://root:mysql@localhost:3306/student_db")
# 创建数据库操作对象
sql_database = SQLDatabase(engine)
print(sql_database.get_usable_table_names())
#
# sql_query_engine = NLSQLTableQueryEngine(
#     sql_database=sql_database,
#     llm=deepseek_llm(),
#     verbose=True,
# )
print(sql_database.get_single_table_info("students"))
# response = sql_query_engine.query("获取所有学生的基本信息")
# print(response)


